using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;
using Utility;

namespace BUS
{
    class TRANGTHAISANPHAMBUS
    {
        public static void Insert(TRANGTHAISP ttsp)
        {
            TRANGTHAISANPHAMDAL ttspDAL = new TRANGTHAISANPHAMDAL();
            ttspDAL.Insert(ttsp);
        }
        public static void Update(TRANGTHAISP ttsp)
        {
            TRANGTHAISANPHAMDAL ttspDAL = new TRANGTHAISANPHAMDAL();
            ttspDAL.Update(ttsp);
        }
        public static void Delete(int iD)
        {
            TRANGTHAISANPHAMDAL ttspDAL = new TRANGTHAISANPHAMDAL();
            ttspDAL.Delete(iD);
        }
        public static Trangthai_spCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            TRANGTHAISANPHAMDAL ttspDAL = new TRANGTHAISANPHAMDAL();
            return ttspDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static Trangthai_spCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            TRANGTHAISANPHAMDAL ttspDAL = new TRANGTHAISANPHAMDAL();
            return ttspDAL.Get(cri.Criter, 0, 0, Trangthai_spColumns.Mattsp.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static TRANGTHAISP GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, Trangthai_spColumns.Mattsp.ToString(), Condition.EQUAL, iD);
            TRANGTHAISANPHAMDAL ttspDAL = new TRANGTHAISANPHAMDAL();
            Trangthai_spCollection trangthaispCollection = ttspDAL.Get(cri.Criter, 0, 0, Trangthai_spColumns.Mattsp.ToString(), OrderDirection.ASC.ToString(), out total);
            if (trangthaispCollection.Count > 0)
                return trangthaispCollection[0];
            return null;
        }
        public static Trangthai_spCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TRANGTHAISANPHAMDAL ttspDAL = new TRANGTHAISANPHAMDAL();
            return ttspDAL.Get(cri.Criter, 1, number,
             Trangthai_spColumns.Mattsp.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static Trangthai_spCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TRANGTHAISANPHAMDAL ttspDAL = new TRANGTHAISANPHAMDAL();
            return ttspDAL.Get(cri.Criter, 1, number,
               Trangthai_spColumns.Mattsp.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
